package ua.edu.nuos.jeetraining2012.cms.util.google.api.predefined;

import java.io.File;

/**
 * Predefined variables that can be useful with Google API.
 *
 * @author Victor N. Ganichev victor.ganichev@gmail.com
 * @version 1.0 Date: 09.06.13 Time: 16:36
 * @since 1.0
 */
final public class StandardGoogleApiVariables {

    /** Define APPLICATION NAME for Google */
    final public static String APPLICATION_NAME = "java2ee courses/1.0";

    /** Define file with Client ID & Client Secret */
    final public static String AUTH_KEY_FILE = "/google/client_secrets.json";

    /** Define common upload dir for all file types */
    final public static String UPLOAD_DIR = "/tmp/uploads/";

    /** Define catalog to save session keys. */
    final public static String KEY_CHAIN_DIR = "/tmp/";

    /** Set user's email */
    final public static String GOOGLE_USER_EMAIL = "java2ee.training@gmail.com";

    final public static String GOOGLE_SERVICE_ACCOUNT_EMAIL = "883953130888-3rkl5m2u9uh2u23okj9evg7ulvcoibk2@developer.gserviceaccount.com";

    final public static String GOOGLE_SERVICE_ACCOUNT_ID = "883953130888-3rkl5m2u9uh2u23okj9evg7ulvcoibk2.apps.googleusercontent.com";

    /**
     * Check is {@link StandardGoogleApiVariables#UPLOAD_DIR} exists or not.
     * If createOnNotExists flag is set, then directory will be created.
     *
     * @param createOnNotExists     Should create catalog on not exists.
     * @return                      True if catalog exists.
     */
    public static boolean isUploadDirExists(boolean createOnNotExists) {
        java.io.File uploadDir = new File(UPLOAD_DIR);
        if (createOnNotExists) {
            if (!uploadDir.exists()) {
                return uploadDir.mkdir();
            }
        }
        return uploadDir.exists();
    }

}
